#include<bits/stdc++.h>
using namespace std;
/*成功的快排*/
#define N 100
class solution{
    public:
        int quick(int *a,int s,int e){
            int rc;
            while(s<e){
                rc = a[s];
                while(s<e&&a[e]>=rc){
                    e--;
                }
                a[s] = a[e];
                
                while(s<e&&a[s]<=rc){
                    s++;
                }
                a[e] = a[s];
            }
            a[s] = rc;
            return s;
        }
        void getarray(){
            cout<<"Enter a key\n";
            scanf("%d",&n);
            cout<<"OK\n";
            for(int i=0;i<n;i++){
                cin>>a[i];
            }
            cout<<"Success\n";
        }
        void sol(int s,int e){
            if(s<e){
                int piviot = quick(a,s,e);
                sol(s,piviot-1);
                sol(piviot+1,e);
            }
        }
        void main_process(){
            getarray();
            sol(0,n-1);
            out();
        }
        void out(){
            for(int i=0;i<n;i++){
                cout<<a[i]<<" ";

            }
        }
    private:
        int a[N];
        int n;
};
int main(int argc,char* argv[]){
    solution a;
    a.main_process();
}